package com.example.whever.lacation;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.whever.R;
import com.example.whever.weather.Weather;

import java.util.List;

public class WeatherListAdapter extends BaseAdapter {
    private final List<Weather> weatherList;
    private final Context context;

    public WeatherListAdapter(List<Weather> weatherList, Context context) {
        this.weatherList = weatherList;
        this.context = context;
    }

    @Override
    public int getCount() {
        return weatherList.size();
    }

    @Override
    public Object getItem(int position) {
        return weatherList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        Weather weather= (Weather) getItem(position);
        convertView=LayoutInflater.from(context).inflate(R.layout.zaa,null);
        TextView dateTextView=convertView.findViewById(R.id.weather_date_text);
        dateTextView.setText(weather.getDate());
        TextView minTempTextView=convertView.findViewById(R.id.weather_min_temp_text);
        minTempTextView.setText(weather.getMinTemp());
        TextView maxTempTextView=convertView.findViewById(R.id.weather_max_temp_text);
        maxTempTextView.setText(weather.getMaxTemp());
        TextView dayText=convertView.findViewById(R.id.weather_day_text);
        dayText.setText(weather.getTextDay());
        return convertView;
    }
}
